Re: [SQL] select ... from ... where ... ~* 'C++'
От | Herouth Maoz |
---|---|
Тема | Re: [SQL] select ... from ... where ... ~* 'C++' |
Дата | |
Msg-id | l03130308b3f993f5266f@[147.233.159.109] обсуждение исходный текст |
Ответ на | select ... from ... where ... ~* 'C++' (Martin Dolog <dolog@mcprogress.com>) |
Список | pgsql-sql |
At 17:33 +0300 on 04/09/1999, Martin Dolog wrote: > PLease, how can I make case insensitive query > which work with string like 'C++' too ? > > select something from something_t where some ~* 'C++' You should read the manual page for regex - it explains which characters are special in a regular expression. In principle, you should add two backslashes before each special character, like '.', '*', '+', '?', '[' etc. SELECT something FROM something_t WHERE some ~* 'C\\+\\+'; If you are wondering why *two* backslashes... Well... If you put one backslash, it tells postgres that the next character is to be taken literally. Thus, if your string is 'C\+\+', it will pass 'C++' to the regexp level, because the parsing of the string is done before passing them to the regexp function. Using two backslashes, the first backslash passes the second literally, so the regexp function gets 'C\+\+'. It then knows that the pluses are not to be considered special. Passing a backslash, I suspect, requires writing no less than four backslashes in the query... Herouth -- Herouth Maoz, Internet developer. Open University of Israel - Telem project http://telem.openu.ac.il/~herutma
В списке pgsql-sql по дате отправления: